/**
 *  cnpm i express --save
 *  cnpm i cors   --save
 * */

var express = require('express')
var app = new express();
var cors = require('cors');

/*支持post请求*/
var bodyParse = require('body-parser')
app.use(bodyParse.urlencoded({extended:false}))
app.use(bodyParse.json());  // 把post提交的参数变成json对象

var stockRouter = require('./router/stock')
var productRouter =require('./router/product')

app.use(cors());
app.use('/stock', stockRouter);
app.use('/pro',productRouter);

var server = app.listen(3000,'localhost',function () {

    var host = server.address().address;
    var port = server.address().port;

    console.log("the server is running on http://%s:%s",host,port);

})